//
//  GGTWebViewController.m
//  GGT
//
//  Created by 空空空 on 14/11/6.
//  Copyright (c) 2014年 GGT. All rights reserved.
//

#import "GGTWebViewController.h"
#import "GGTAppDelegate.h"
@interface GGTWebViewController ()<DPRequestDelegate>
@property (nonatomic, retain)UIWebView *webView;

@property (nonatomic, retain)NSString *shopId;
@end

@implementation GGTWebViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
//创建webView
    self.view.backgroundColor = [UIColor whiteColor];
    self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, -50, self.view.frame.size.width, self.view.frame.size.height + 50)];
    [self.view addSubview:self.webView];
//数据解析
//    获取指定团购信息
    NSString *url = @"v1/deal/get_single_deal";
    NSString *params = [NSString stringWithFormat:@"deal_id=%@", self.dealId];
    [[[GGTAppDelegate instance] dpapi] requestWithURL:url paramsString:params delegate:self];
    
    
        [self.view addSubview: self.webView];
}
- (void)request:(DPRequest *)request didFinishLoadingWithResult:(id)result
{
    NSDictionary *dic = [[result objectForKey:@"deals"]lastObject];
    self.shopId = [dic objectForKey:@"deal_h5_url"];
//    webView方法
    NSURLRequest *request1 =[NSURLRequest requestWithURL:[NSURL URLWithString:self.shopId]];
    [self.webView loadRequest:request1];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
